import java.awt.Color;
import java.awt.ComponentOrientation;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.ArrayList;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JToggleButton;
import javax.swing.SwingConstants;

public class Bot extends JFrame implements ActionListener {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	private Socket socket = null;
	private BotInputThread myInputThread;

	PrintWriter out = null;
	BufferedReader in = null;
	private JPanel contentPane;
	private JTextField hostname, port, input;

	int dealerPlayerID, smallBlindID, bigBlindID, activePlayerID, betID;
	int numberOfPlayers, pot, roundNumber;
	java.util.List<Player> players;
	JTextArea output;
	String message;

	ArrayList<JToggleButton> bCards;
	ArrayList<JLabel> lSeats;
	ArrayList<JTextArea> tBankrolls;
	ArrayList<JLabel> backBankrolls;
	ArrayList<JTextArea> tSpecialButtons;
	ArrayList<JLabel> lBacks;
	ArrayList<JLabel> lDealerButtons;
	ArrayList<JTextArea> tIdPlayers;
	ArrayList<JLabel> lBets;
	ArrayList<JTextArea> tBets;
	ArrayList<JLabel> lFoldSeats;

	JTextArea tBet;
	JTextArea potView;
	JTextArea messageView;
	JTextArea betsView;
	JTextArea roundView;

	JButton connect, send;

	JTextArea tMyID;
	JLabel lMyID;
	JTextArea tMyCoins;
	JLabel lMyCoins;
	JTextArea tMyBet;
	JLabel lMyBet;



	JLabel lRound;
	JLabel TableIcon;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {

		EventQueue.invokeLater(new Runnable() {
			@Override
			public void run() {
				try {
					Bot frame = new Bot();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame for poker room.
	 *
	 * @throws IOException
	 */
	public Bot() throws IOException {
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 900, 675);
		contentPane = new JPanel();
		// contentPane.setName("[Player1]\r\n[Bot]");
		// contentPane.setForeground(Color.YELLOW);
		contentPane.setBackground(new Color(1, 10, 15));
		// contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		/**
		 * Create four button for player cards.
		 *
		 */
		bCards = new ArrayList<JToggleButton>();
		JToggleButton bCardNo1 = this.createCard(10, "spade.png");
		bCards.add(bCardNo1);

		JToggleButton bCardNo2 = this.createCard(134, "heart.png");
		bCards.add(bCardNo2);

		JToggleButton bCardNo3 = this.createCard(260, "diamond.png");
		bCards.add(bCardNo3);

		JToggleButton bCardNo4 = this.createCard(383, "club.png");
		bCards.add(bCardNo4);

		/**
		 * JTextArea tMyID information which the player I am JLabel lMyID
		 */
		tMyID = new JTextArea();
		tMyID.setForeground(Color.RED);
		tMyID.setEditable(false);
		tMyID.setOpaque(false);
		tMyID.setBounds(630, 473, 50, 45);
		tMyID.setFont(new Font("Comic Sans MS", Font.PLAIN, 22));
		contentPane.add(tMyID);

		lMyID = new JLabel();
		lMyID.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
		lMyID.setIcon(new ImageIcon(Bot.class.getResource("playerID.png")));
		lMyID.setVerticalAlignment(SwingConstants.TOP);
		lMyID.setBounds(516, 469, 160, 45);
		contentPane.add(lMyID);

		/**
		 * JTextArea tMyCoins display information about my actual count of coin
		 * Label lMyCoins
		 */
		tMyCoins = new JTextArea();
		tMyCoins.setForeground(Color.WHITE);
		tMyCoins.setEditable(false);
		tMyCoins.setOpaque(false);
		tMyCoins.setBounds(570, 525, 70, 20);
		tMyCoins.setFont(new Font("Comic Sans MS", Font.PLAIN, 14));
		contentPane.add(tMyCoins);

		lMyCoins = new JLabel();
		lMyCoins.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
		lMyCoins.setIcon(new ImageIcon(Bot.class.getResource("myCoins.png")));
		lMyCoins.setVerticalAlignment(SwingConstants.TOP);
		lMyCoins.setBounds(516, 507, 160, 45);
		contentPane.add(lMyCoins);

		/**
		 * JTextArea tMyBet display information about my actual bet Label lMyBet
		 */
		tMyBet = new JTextArea();
		tMyBet.setForeground(Color.WHITE);
		tMyBet.setEditable(false);
		tMyBet.setOpaque(false);
		tMyBet.setBounds(570, 565, 70, 20);
		tMyBet.setFont(new Font("Comic Sans MS", Font.PLAIN, 14));
		contentPane.add(tMyBet);

		lMyBet = new JLabel();
		lMyBet.setIcon(new ImageIcon(Bot.class.getResource("myBet.png")));
		lMyBet.setVerticalAlignment(SwingConstants.TOP);
		lMyBet.setBounds(516, 547, 160, 40);
		contentPane.add(lMyBet);

		lFoldSeats = new ArrayList<JLabel>();
		JLabel lFold1Seat = this.createFoldSeat(405, 300);
		lFoldSeats.add(lFold1Seat);

		JLabel lFold2Seat = this.createFoldSeat(200, 300);
		lFoldSeats.add(lFold2Seat);

		JLabel lFold3Seat = this.createFoldSeat(3, 230);
		lFoldSeats.add(lFold3Seat);

		JLabel lFold4Seat = this.createFoldSeat(2, 70);
		lFoldSeats.add(lFold4Seat);

		JLabel lFold5Seat = this.createFoldSeat(198, 30);
		lFoldSeats.add(lFold5Seat);

		JLabel lFold6Seat = this.createFoldSeat(385, 30);
		lFoldSeats.add(lFold6Seat);
		/**
		 *
		 */
		tIdPlayers = new ArrayList<JTextArea>();
		JTextArea tIdPlayer1 = this.createPlayerId("Player  0", 413, 286);
		tIdPlayers.add(tIdPlayer1);

		JTextArea tIdPlayer2 = this.createPlayerId("Player  1", 207, 286);
		tIdPlayers.add(tIdPlayer2);

		JTextArea tIdPlayer3 = this.createPlayerId("Player  2", 2, 215);
		tIdPlayers.add(tIdPlayer3);

		JTextArea tIdPlayer4 = this.createPlayerId("Player  3", 20, 54);
		tIdPlayers.add(tIdPlayer4);

		JTextArea tIdPlayer5 = this.createPlayerId("Player  4", 207, 15);
		tIdPlayers.add(tIdPlayer5);

		JTextArea tIdPlayer6 = this.createPlayerId("Player  5", 393, 15);
		tIdPlayers.add(tIdPlayer6);

		/**
		 *
		 */
		tBankrolls = new ArrayList<JTextArea>();
		JTextArea tBankroll1 = this.createBankroll(455, 348);
		tBankrolls.add(tBankroll1);

		JTextArea tBankroll2 = this.createBankroll(250, 348);
		tBankrolls.add(tBankroll2);

		JTextArea tBankroll3 = this.createBankroll(47, 277);
		tBankrolls.add(tBankroll3);

		JTextArea tBankroll4 = this.createBankroll(65, 115);
		tBankrolls.add(tBankroll4);

		JTextArea tBankroll5 = this.createBankroll(250, 75);
		tBankrolls.add(tBankroll5);

		JTextArea tBankroll6 = this.createBankroll(435, 75);
		tBankrolls.add(tBankroll6);

		/**
		 *
		 */
		backBankrolls = new ArrayList<JLabel>();
		JLabel backBankroll1 = this.createBankrollBack(455, 348);
		backBankrolls.add(backBankroll1);

		JLabel backBankroll2 = this.createBankrollBack(250, 348);
		backBankrolls.add(backBankroll2);

		JLabel backBankroll3 = this.createBankrollBack(47, 277);
		backBankrolls.add(backBankroll3);

		JLabel backBankroll4 = this.createBankrollBack(65, 115);
		backBankrolls.add(backBankroll4);

		JLabel backBankroll5 = this.createBankrollBack(250, 75);
		backBankrolls.add(backBankroll5);

		JLabel backBankroll6 = this.createBankrollBack(435, 75);
		backBankrolls.add(backBankroll6);

		/**
		 *
		 */
		tSpecialButtons = new ArrayList<JTextArea>();
		JTextArea tSpecialButton1 = this.createSpecialButton(455, 368);
		tSpecialButtons.add(tSpecialButton1);

		JTextArea tSpecialButton2 = this.createSpecialButton(250, 368);
		tSpecialButtons.add(tSpecialButton2);

		JTextArea tSpecialButton3 = this.createSpecialButton(47, 297);
		tSpecialButtons.add(tSpecialButton3);

		JTextArea tSpecialButton4 = this.createSpecialButton(65, 135);
		tSpecialButtons.add(tSpecialButton4);

		JTextArea tSpecialButton5 = this.createSpecialButton(250, 95);
		tSpecialButtons.add(tSpecialButton5);

		JTextArea tSpecialButton6 = this.createSpecialButton(435, 95);
		tSpecialButtons.add(tSpecialButton6);
		


		/**
		 *
		 */
		lBacks = new ArrayList<JLabel>();
		JLabel back1 = this.createSpecialButtonBack(455, 368);
		lBacks.add(back1);

		JLabel back2 = this.createSpecialButtonBack(250, 368);
		lBacks.add(back2);

		JLabel back3 = this.createSpecialButtonBack(47, 297);
		lBacks.add(back3);

		JLabel back4 = this.createSpecialButtonBack(65, 135);
		lBacks.add(back4);

		JLabel back5 = this.createSpecialButtonBack(250, 95);
		lBacks.add(back5);

		JLabel back6 = this.createSpecialButtonBack(435, 95);
		lBacks.add(back6);

		/**
		 *
		 */
		tBets = new ArrayList<JTextArea>();
		JTextArea tBet1 = this.createTextBet(475, 385);
		tBets.add(tBet1);

		JTextArea tBet2 = this.createTextBet(270, 385);
		tBets.add(tBet2);

		JTextArea tBet3 = this.createTextBet(67, 314);
		tBets.add(tBet3);

		JTextArea tBet4 = this.createTextBet(85, 152);
		tBets.add(tBet4);

		JTextArea tBet5 = this.createTextBet(455, 112);
		tBets.add(tBet5);

		JTextArea tBet6 = this.createTextBet(270, 112);
		tBets.add(tBet6);

		/**
		 *
		 */
		lBets = new ArrayList<JLabel>();
		JLabel lBet1 = this.createIconBet(455, 388);
		lBets.add(lBet1);

		JLabel lBet2 = this.createIconBet(250, 388);
		lBets.add(lBet2);

		JLabel lBet3 = this.createIconBet(47, 317);
		lBets.add(lBet3);

		JLabel lBet4 = this.createIconBet(65, 155);
		lBets.add(lBet4);

		JLabel lBet5 = this.createIconBet(250, 115);
		lBets.add(lBet5);

		JLabel lBet6 = this.createIconBet(435, 115);
		lBets.add(lBet6);

		/**
		 *
		 */
		lSeats = new ArrayList<JLabel>();
		JLabel lSeat1Icon = this.createSeat(396, 257);
		lSeats.add(lSeat1Icon);

		JLabel lSeat2Icon = this.createSeat(190, 257);
		lSeats.add(lSeat2Icon);

		JLabel lSeat3Icon = this.createSeat(-15, 186);
		lSeats.add(lSeat3Icon);

		JLabel lSeat4Icon = this.createSeat(3, 25);
		lSeats.add(lSeat4Icon);

		JLabel lSeat5Icon = this.createSeat(190, -14);
		lSeats.add(lSeat5Icon);

		JLabel lSeat6Icon = this.createSeat(376, -14);
		lSeats.add(lSeat6Icon);

		/**
		 *
		 */
		lDealerButtons = new ArrayList<JLabel>();
		JLabel lDealerB1 = this.createDealerButton(544, 288);
		lDealerButtons.add(lDealerB1);

		JLabel lDealerB2 = this.createDealerButton(339, 288);
		lDealerButtons.add(lDealerB2);

		JLabel lDealerB3 = this.createDealerButton(130, 222);
		lDealerButtons.add(lDealerB3);

		JLabel lDealerB4 = this.createDealerButton(170, 120);
		lDealerButtons.add(lDealerB4);

		JLabel lDealerB5 = this.createDealerButton(350, 105);
		lDealerButtons.add(lDealerB5);

		JLabel lDealerB6 = this.createDealerButton(540, 105);
		lDealerButtons.add(lDealerB6);

		/**
		 * Add picture as a button. Button check, bet, raise, call, fold,
		 * all-in, change card
		 */

		roundView = new JTextArea("");
		roundView.setEditable(false);
		roundView.setFont(new Font("Andalus", Font.BOLD, 28));
		roundView.setOpaque(false);
		roundView.setForeground(Color.ORANGE);
		roundView.setBounds(815, 26, 300, 120);
		contentPane.add(roundView);

		lRound = new JLabel();
		lRound.setIcon(new ImageIcon(Bot.class.getResource("round.png")));
		lRound.setVerticalAlignment(SwingConstants.TOP);
		lRound.setBounds(704, 25, 160, 44);
		contentPane.add(lRound);

		connect = new JButton(new ImageIcon(Bot.class.getResource("connect.png")));
		connect.setBorderPainted(false);
		connect.setContentAreaFilled(false);
		connect.setDisabledIcon(new ImageIcon(Bot.class.getResource("backButton.png")));
		connect.setVerticalAlignment(SwingConstants.TOP);
		connect.setBounds(714, 438, 170, 50);
		contentPane.add(connect);
		connect.addActionListener(this);

		hostname = new JTextField();
		hostname.setForeground(Color.WHITE);
		hostname.setFont(new Font("Segoe UI", Font.BOLD, 13));
		hostname.setDisabledTextColor(new Color(102, 102, 153));
		hostname.setCaretColor(new Color(0, 204, 51));
		hostname.setBackground(new Color(1, 10, 15));
		hostname.setText("localhost");
		hostname.setBounds(727, 387, 141, 23);
		contentPane.add(hostname);
		hostname.setColumns(10);

		port = new JTextField();
		port.setForeground(Color.WHITE);
		port.setFont(new Font("Segoe UI", Font.BOLD, 13));
		port.setDisabledTextColor(new Color(102, 102, 153));
		port.setCaretColor(new Color(0, 204, 51));
		port.setBackground(new Color(1, 10, 15));
		port.setText("5000");
		port.setBounds(727, 419, 141, 23);
		contentPane.add(port);
		port.setColumns(10);

		input = new JTextField();
		input.setBounds(727, 491, 86, 20);
		contentPane.add(input);
		input.setColumns(10);

		send = new JButton("send");
		send.setBounds(724, 522, 89, 23);
		contentPane.add(send);
		send.addActionListener(this);

		output = new JTextArea("");
		final JScrollPane scroll = new JScrollPane(output);
		scroll.setBounds(724, 562, 114, 80);
		output.setBackground(Color.WHITE);
		output.setBounds(724, 562, 114, 80);
		contentPane.add(scroll);


		potView = new JTextArea("Pot: ");
		potView.setEditable(false);
		potView.setForeground(Color.LIGHT_GRAY);
		potView.setFont(new Font("Comic Sans MS", Font.PLAIN, 18));
		potView.setOpaque(false);
		potView.setBounds(320, 220, 80, 30);
		contentPane.add(potView);
		
		messageView = new JTextArea(" ");
		messageView.setEditable(false);
		messageView.setForeground(Color.WHITE);
		messageView.setFont(new Font("Comic Sans MS", Font.PLAIN, 18));
		messageView.setOpaque(false);
		messageView.setBounds(320, 195, 300, 30);
		contentPane.add(messageView);

		/*
		 * betsView = new JTextArea(""); betsView.setEditable(false);
		 * betsView.setForeground(Color.LIGHT_GRAY); betsView.setFont(new
		 * Font("Comic Sans MS", Font.PLAIN, 18)); betsView.setOpaque(false);
		 * betsView.setBounds(225, 222, 200, 60); contentPane.add(betsView);
		 */

		/**
		 * Label with table icon
		 */

		TableIcon = new JLabel();
		TableIcon.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
		TableIcon.setIcon(new ImageIcon(Bot.class.getResource("PokerTable.png")));
		TableIcon.setBounds(32, 66, 630, 330);
		contentPane.add(TableIcon);
	}

	@Override
	public void actionPerformed(ActionEvent event) {

		if (event.getSource() == connect) {
			try {
				connect.setEnabled(false);
				listenSocket(hostname.getText(), port.getText());
			} catch (ListenException e) {
				System.out.println(e.getMessage());
			}
		} else if (event.getSource() == send) {
			message = input.getText();
			out.println(message);
			input.setText("");
		}
	}

	// po kliknieciu connect
	public void listenSocket(String address, String p) throws ListenException {

		int port;
		try {
			port = Integer.parseInt(p);
			socket = new Socket(address, port);
			out = new PrintWriter(socket.getOutputStream(), true);
			in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
		} catch (NumberFormatException e) {
			throw new ListenException("Illegal port number : " + p + ".");
		} catch (UnknownHostException e) {
			throw new ListenException("Unknown host: " + address);
		} catch (IOException e) {
			throw new ListenException("No I/O.");
		}
		myInputThread = new BotInputThread(this);
		myInputThread.start();
	}

	/**
	 * Update the picture of the card for a given button
	 *
	 * @param card
	 * @param picture
	 */
	public void setCard(JToggleButton card, String picture) {
		card.setSelected(false);
		card.setIcon((new ImageIcon(Bot.class.getResource(picture))));
		card.setSelectedIcon(new ImageIcon(Bot.class.getResource(picture)));

	}

	/**
	 *
	 * @param left
	 * @param selectedImage
	 * @param disabledImage
	 * @return
	 */
	public JToggleButton createCard(int left,String disabledImage) {
		JToggleButton bCard = new JToggleButton();
		bCard.setVerticalAlignment(SwingConstants.CENTER);
		bCard.setSelectedIcon(new ImageIcon(Bot.class.getResource(disabledImage)));
		bCard.setIcon(new ImageIcon(Bot.class.getResource(disabledImage)));
		bCard.setBorderPainted(false);
		bCard.setContentAreaFilled(false);
		bCard.setBounds(left, 475, 123, 150);
		bCard.addActionListener(this);
		contentPane.add(bCard);
		return bCard;
	}

	/**
	 * Method of creating seat
	 *
	 * @param left
	 * @param right
	 * @return
	 */

	public JLabel createSeat(int left, int right) {
		JLabel lSeat = new JLabel();
		lSeat.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); //
		lSeat.setOpaque(false);
		lSeat.setIcon(new ImageIcon(Bot.class.getResource("ACTuser.png")));
		lSeat.setDisabledIcon(new ImageIcon(Bot.class.getResource("user.png")));
		lSeat.setBounds(left, right, 150, 150);
		lSeat.setVisible(false);
		contentPane.add(lSeat);
		return lSeat;

	}

	public JLabel createFoldSeat(int left, int right) {
		JLabel lFoldSeat = new JLabel();
		lFoldSeat.setIcon(new ImageIcon(Bot.class.getResource("iconFold1.png")));
		lFoldSeat.setBounds(left, right, 150, 150);
		lFoldSeat.setVisible(false);
		contentPane.add(lFoldSeat);
		return lFoldSeat;
	}

	/**
	 * Method of creating SpecialButton
	 *
	 * @param left
	 * @param right
	 * @return
	 */
	public JTextArea createSpecialButton(int left, int right) {
		JTextArea tSpecialButton = new JTextArea();
		tSpecialButton.setEditable(false);
		tSpecialButton.setOpaque(false);
		tSpecialButton.setFont(new Font("Comic Sans MS", Font.PLAIN, 16));
		tSpecialButton.setText("");
		tSpecialButton.setVisible(false);
		tSpecialButton.setBounds(left, right, 100, 20);
		contentPane.add(tSpecialButton);
		return tSpecialButton;
	}

	/**
	 * Method of creating background SpeciaButton
	 *
	 * @param left
	 * @param right
	 * @return
	 */
	public JLabel createSpecialButtonBack(int left, int right) {
		JLabel lBack = new JLabel();
		lBack.setIcon(new ImageIcon(Bot.class.getResource("textbackground.png")));
		lBack.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
		lBack.setVisible(false);
		lBack.setBounds(left, right, 110, 20);
		contentPane.add(lBack);
		return lBack;

	}

	/**
	 * Method of creating Bankroll
	 *
	 * @param left
	 * @param right
	 * @return
	 */
	public JTextArea createBankroll(int left, int right) {
		JTextArea tBankroll = new JTextArea();
		tBankroll.setEditable(false);
		tBankroll.setOpaque(false);
		tBankroll.setFont(new Font("Comic Sans MS", Font.PLAIN, 16));
		tBankroll.setForeground(Color.WHITE);
		tBankroll.setText("");
		tBankroll.setVisible(false);
		tBankroll.setBounds(left, right, 100, 20);
		contentPane.add(tBankroll);
		return tBankroll;
	}

	/**
	 * Method of creating backgrounf Bankroll
	 *
	 * @param left
	 * @param right
	 * @return
	 */
	public JLabel createBankrollBack(int left, int right) {
		JLabel tBankrollBack = new JLabel();
		tBankrollBack.setVisible(false);
		tBankrollBack.setIcon(new ImageIcon(Bot.class.getResource("textbackground2.png")));
		tBankrollBack.setBounds(left, right, 100, 20);
		contentPane.add(tBankrollBack);
		return tBankrollBack;
	}

	/**
	 * Method of creating dealer button
	 *
	 * @param left
	 * @param right
	 * @return
	 */
	public JLabel createDealerButton(int left, int right) {
		JLabel lDealerButton = new JLabel();
		lDealerButton.setIcon(new ImageIcon(Bot.class.getResource("dealerButton.png")));
		lDealerButton.setVisible(false);
		lDealerButton.setBounds(left, right, 50, 45);
		contentPane.add(lDealerButton);
		return lDealerButton;
	}

	/**
	 * Method of creating playerID
	 *
	 * @param ID
	 * @param left
	 * @param right
	 * @return
	 */
	public JTextArea createPlayerId(String ID, int left, int right) {
		JTextArea tIdPlayer = new JTextArea(ID);
		tIdPlayer.setForeground(Color.WHITE);
		tIdPlayer.setFont(new Font("Comic Sans MS", Font.BOLD, 21));
		tIdPlayer.setBounds(left, right, 99, 30);
		tIdPlayer.setEditable(false);
		tIdPlayer.setOpaque(false);
		tIdPlayer.setVisible(false);
		contentPane.add(tIdPlayer);
		return tIdPlayer;
	}

	/**
	 * Method of creating text on Bet label
	 *
	 * @param left
	 * @param right
	 * @return
	 */
	public JTextArea createTextBet(int left, int right) {
		JTextArea tBet = new JTextArea();
		tBet.setForeground(Color.WHITE);
		tBet.setFont(new Font("Comic Sans MS", Font.BOLD, 15));
		tBet.setBounds(left, right, 60, 20);
		tBet.setEditable(false);
		tBet.setOpaque(false);
		contentPane.add(tBet);
		return tBet;
	}

	/**
	 * Method of creating Bet image
	 *
	 * @param left
	 * @param right
	 * @return
	 */
	public JLabel createIconBet(int left, int right) {
		JLabel lBet = new JLabel();
		lBet.setIcon(new ImageIcon(Bot.class.getResource("blackIcon.png")));
		lBet.setVisible(false);
		lBet.setBounds(left, right, 100, 20);
		contentPane.add(lBet);
		return lBet;
	}

	/**
	 * 1. Select player (me) 2. Loop over cards marked to be exchanged and build
	 * CEN command 3. If command is empty, do not send it
	 */
	public void callActionChangeCard() {
		Player me = this.players.get(activePlayerID);
		String toChange = new String();
		for (Card card : me.cardsToExchange) {
			toChange = toChange + " " + card.toString();
		}
		int toComplete = me.hand.cards.size() - me.cardsToExchange.size();
		for (int i = 0; i < toComplete; i++) {
			toChange = toChange + " 00";
		}
		if (!toChange.isEmpty()) {
			System.out.println("Cards to be exchanged" + toChange);
			out.println("CEN" + toChange);
		}
		// out.println("CRE" + toChange);
	}

	// public void getLabel() {
	// Player me = this.players.get(activePlayer);

	// return null;
}
